package com.ruoyi.common.enums;

/**
 * 质检状态类
 */
public enum QualityCheckStatus {
    NOT_INSPECTED("4", "未质检"),
    IN_PROGRESS("0", "质检中"),
    COMPLETED("1", "已完成"),
    CANCELLED("2", "已质检（已撤销）"),
    PENDING_REVIEW("3", "待审核"),
    PARTIALLY_INSPECTED("5", "部分质检"); // 新增状态

    private final String code; // 质检状态的代码
    private final String description; // 质检状态的描述

    // 构造函数
    QualityCheckStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    // 获取状态代码
    public String getCode() {
        return code;
    }

    // 获取状态描述
    public String getDescription() {
        return description;
    }

    // 根据状态代码获取对应的枚举项
    public static QualityCheckStatus fromCode(String code) {
        for (QualityCheckStatus status : QualityCheckStatus.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }
}
